package test;

import java.util.concurrent.CountDownLatch;

public class Demo {

    private static CountDownLatch countDownLatch = new CountDownLatch(100);


    public static void main(String[] args) {

        for (int i = 0; i < 100; i++) {

            System.out.println(1);
            new Thread(()->{
                countDownLatch.countDown();

                try {
                    countDownLatch.await();
                    System.out.println(Thread.currentThread().getName());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }).start();

        }

    }

}
